import request from '@/utils/request'

export function getFlashsaleUsableList(query) {
  let baseUrl = "/marketing/flashsale"
  if(query != undefined){
    if(typeof query == "object"){
      console.log(query)
      if(query.hasOwnProperty('flashsaleID')){
        query['flashsaleID'] = parseInt(query['flashsaleID'])
        if(isNaN(query['flashsaleID']) == false){
          baseUrl = baseUrl+"-"+query['flashsaleID']
        }
      }
    }
  }
  return request({
    url: baseUrl,
    method: 'get'
  })
}

export function getFlashsaleList(query) {
  return request({
    url: '/marketing/admin/flashsale/getList',
    method: 'post',
    data: query
  })
}
export function saveFlashsale(query) {
  return request({
    url: '/marketing/admin/flashsale/save',
    method: 'post',
    data: query
  })
}

export function removeFlashsale(query) {
  return request({
    url: '/marketing/admin/flashsale/remove',
    method: 'post',
    data: query
  })
}
export function getFlashsaleDetail(query) {
  if(query != undefined){
    query = JSON.parse(JSON.stringify(query))
  }
  return request({
    url: '/marketing/admin/flashsale/info/0',
    method: 'get',
    data: query
  })
}